import type { FreqBand, AdjustItem, FactorResult, LineItem, LineCal, PositionItem, Positioncal } from "./index.d";
import { nodeItem } from "../../common/index.js";
import { createCommand } from '../../commandHelper';

// 模块ID（替代原来的path，对应CalibrationModule的config.id）
const moduleId = 'CalibrationForm';


// const sendCmd = inject<(cmd: string, params?: any) => any>('send-calib-cmd')!;

// const path = "/api/Calibration/SendCommand";


/**
 * @description: 获取频段列表
 */
export const getFreqScopes = createCommand<{}, AdjustItem[]>(moduleId, { command: "GetFreqScopes" });
/**
 * @description: 新增频段列表
 */
export const addFreqScope = createCommand<{ freqScope: AdjustItem }, AdjustItem>(moduleId, { command: "AddFreqScope" });
/**
 * @description: 更新频段列表
 */
export const updateFreqScope = createCommand<{ freqScope: AdjustItem }, AdjustItem>(moduleId, { command: "UpdateFreqScope" });
/**
 * @description: 删除频段列表
 */
export const removeFreqScope = createCommand<{ freqScopeId: string }, boolean>(moduleId, { command: "RemoveFreqScope" });
/**
 * @description: 获取频点列表
 */
export const getFreqBands = createCommand<{ freqScopeId: string }, FreqBand[]>(moduleId, { command: "GetFreqBands" });
/**
 * @description: 新增频点
 */
export const addFreqBand = createCommand<{ freqBand: FreqBand }, FreqBand>(moduleId, { command: "AddFreqBand" });
/**
 * @description: 删除频点
 */
export const removeFreqBand = createCommand<{ freqBandId: string }, boolean>(moduleId, { command: "RemoveFreqBand" });

/**
 * @description: 获取所有的天线因子
 */
export const getAntennaFactors = createCommand<{}, AdjustItem[]>(moduleId, { command: "GetAntennaFactors" });
/**
 * @description: 新增天线因子
 */
export const addAntennaFactory = createCommand<{ antennaFactorInfo: AdjustItem }, AdjustItem>(moduleId, { command: "AddAntennaFactory" });
/**
 * @description: 编辑天线因子
 */
export const updateAntennaFactory = createCommand<{ antennaFactorInfo: AdjustItem }, AdjustItem>(moduleId, { command: "UpdateAntennaFactory" });
/**
 * @description: 删除天线因子
 */
export const removeAntennaFactory = createCommand<{ anttennaFactorId: string }, boolean>(moduleId, { command: "RemoveAntennaFactory" });
/**
 * @description: 获取天线因子结果
 */
export const getAntennaFactorResults = createCommand<{ antennaFactorId: string }, FactorResult>(moduleId, { command: "GetAntennaFactorResults" });
/**
 * @description: 新增天线因子结果
 */
export const addAntennaFactorResult = createCommand<{ antennaFactorResult: FactorResult }, FactorResult>(moduleId, { command: "AddAntennaFactorResult" });
/**
 * @description: 删除天线因子结果
 */
export const removeAntennaFactorResult = createCommand<{ antennaFactorResultId: string }, boolean>(moduleId, { command: "RemoveAntennaFactorResult" });

/**
 * @description: 获取新增链路校准的参数
 */
export const getCreateLineParams = createCommand<{ calibrationType: "Reference" | "Gable" }, nodeItem[]>(moduleId, { command: "GetCreateLineParams" });
/**
 * @description: 获取链路校准列表-参考校准
 */
export const getReferenceLines = createCommand<{ line: LineItem }, LineItem>(moduleId, { command: "GetReferenceLines" });
/**
 * @description: 获取链路校准列表-线缆校准
 */
export const getCableLines = createCommand<{ line: LineItem }, LineItem>(moduleId, { command: "GetCableLines" });
/**
 * @description: 新增链路校准
 */
export const addLine = createCommand<{ line: LineItem }, LineItem>(moduleId, { command: "AddLine" });
/**
 * @description: 编辑链路校准
 */
export const updateLine = createCommand<{ line: LineItem }, LineItem>(moduleId, { command: "UpdateLine" });
/**
 * @description: 删除链路校准
 */
export const removeLine = createCommand<{ lineId: string }, boolean>(moduleId, { command: "RemoveLine" });
/**
 * @description: 链路校准结果
 */
export const getLineCalResults = createCommand<{ lineId: string }, LineCal[]>(moduleId, { command: "GetLineCalResults" });

/**
 * @description: 获取新增位置校准的参数
 */
export const getCreatePositionParams = createCommand<{}, nodeItem[]>(moduleId, { command: "GetCreatePositionParams" });
/**
 * @description: 获取位置校准列表
 */
export const getPositionCalInfos = createCommand<{}, PositionItem[]>(moduleId, { command: "GetPositionCalInfos" });
/**
 * @description: 新增位置校准
 */
export const addPosition = createCommand<{ postionCal: PositionItem }, PositionItem>(moduleId, { command: "AddPosition" });
/**
 * @description: 编辑位置校准
 */
export const updatePositionCal = createCommand<{ positionCal: PositionItem }, PositionItem>(moduleId, { command: "UpdatePositionCal" });
/**
 * @description: 删除位置校准
 */
export const removePositionCal = createCommand<{ postionCalId: string }, boolean>(moduleId, { command: "RemovePositionCal" });
/**
 * @description: 获取位置校准结果
 */
export const getPositionCalResults = createCommand<{ positionId: string }, Positioncal[]>(moduleId, { command: "GetPositionCalResults" });
/**
 * @description: 开始校准
 */
export const startAdjust = createCommand<{ calibrationType: "Line" | "Position"; calirbationId: string }, boolean>(moduleId, { command: "Start" });
/**
 * @description: 停止校准
 */
export const stopAdjust = createCommand<{}, never>(moduleId, { command: "Stop" });
/**
 * @description: 获取校准配置
 */
export const getCurrentInstrumneForms = createCommand<{}, nodeItem[]>(moduleId, { command: "GetCurrentInstrumneForms" });
/**
 * @description: 设置校准配置
 */
export const setCalibrationInstruments = createCommand<{ setform: nodeItem[] }, boolean>(moduleId, { command: "SetCalibrationInstruments" });
